from PIL import Image

# 打开图片
image = Image.open('123.jpg')

# 转化为灰度图
gray_image = image.convert('L')

# 保存灰度图
gray_image.save('gray_image.jpg')